<!--
公告中心修改
 add by yyp 2019-05-14
-->
<template lang="pug">
  kalix-dialog.user-add(bizKey="StudyPlan" ref="kalixBizDialog"
  v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot" style=" width:60%;margin:auto;")
      el-form-item(label="学习计划标题" prop="planTitle" label-width="120px" v-bind:rules="rules.planTitle")
        el-input(v-model="formModel.planTitle" style="width:80%")
      el-form-item(label="学习计划创建日期" prop="planDate" label-width="120px" v-bind:rules="rules.planDate")
        kalix-date-picker(v-model="formModel.planDate" style="width:80%" type="date")
      el-form-item(label="学习计划详情" prop="planContent" label-width="120px" v-bind:rules="rules.planContent")
        el-input(v-model="formModel.planContent" style="width:80%"  type="textarea")
      <!--el-form-item(label="计划开始日期" prop="planStartTime" label-width="120px" v-bind:rules="rules.planStartTime")-->
        <!--el-date-picker(v-model="formModel.planStartTime" type="date" :picker-options="pickerBeginDateBefore" format="yyyy-MM-dd"  placeholder="")-->
      <!--el-form-item(label="计划结束日期" label-width="120px")-->
        <!--el-date-picker(v-model="formModel.planEndTime" type="date" :picker-options="pickerBeginDateBefore" format="yyyy-MM-dd"  placeholder="")-->
      el-form-item(label="计划开始日期" prop="planStartTime" label-width="120px" v-bind:rules="rules.planStartTime")
        kalix-date-picker(v-model="formModel.planStartTime" style="width:80%" type="date"  )
      el-form-item(label="计划结束日期" prop="planEndTime"  label-width="120px" v-bind:rules="rules.planEndTime")
        kalix-date-picker(v-model="formModel.planEndTime" style="width:80%" type="date")
      el-form-item(label="学生ID" prop="studentId" label-width="120px" v-bind:rules="rules.studentId")
        el-input(v-model="formModel.studentId" style="width:80%" )

</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {StudyPlanURL} from '../../config.toml'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  import KalixImgUpload from '../../../../../components/corelib/components/common/imgUpload'
  export default {
    name: 'studyplanEdit',
    components: {
      KalixSelect,
      KalixClansmanUpload,
      KalixImgUpload
    },
    data() {
      return {
        filters: {
          column: {
            create_start_date: '',
            create_end_date: ''
          }
        },
        pickerBeginDateBefore: {
          disabledDate: (time) => {
            let beginDateVal = this.filters.column.create_end_date
            if (beginDateVal) {
              return time.getTime() > beginDateVal
            }
          }
        },
        pickerBeginDateAfter: {
          disabledDate: (time) => {
            let beginDateVal = this.filters.column.create_start_date
            if (beginDateVal) {
              return time.getTime() < beginDateVal
            }
          }
        },
        action: baseURL + '/camel/rest/upload',
        formModel: Object.assign({}, FormModel),
        rules: {
          name: [{required: true, message: '请输入修改的名称', trigger: 'blur'}]
        },
        targetURL: StudyPlanURL,
        labelWidth: '110px'
      }
    },
    methods: {
      ImgDel(imgUrl) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          let arrImg = this.formModel.imgUrl.split(',')
          console.log('arrImg++++++++++++++', arrImg)
          let idx = arrImg.indexOf(imgUrl)
          arrImg.splice(idx, 1)
          this.formModel.imgUrl = arrImg.join(',')
          console.log('this.formModel.imgUrl++++++++++++++', this.formModel.imgUrl)
          // this.filePathArr = arrImg
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)

        this.formModel.newUrl = filePath
        this.formModel.imgName = fileName
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 50%
    margin auto
    .radio
      margin-left 150px
      margin-bottom 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
  .img-margin
    margin-left 150px
</style>
